package com.letv.business.flow.album.model;

import java.util.List;

import com.letv.core.bean.DDUrlsResultBean;
import com.letv.core.utils.LogInfo;
import com.letv.core.utils.PlayUtils;
import com.letv.core.utils.PlayUtils.PLAY_LEVEL;

/**
 * 点播码流支持信息
 * 
 * @author zhuqiao
 *
 */
public class AlbumStreamSupporter {
    /** 当前视频是否有超清 **/
    public boolean hasSuperHd;
    /** 当前视频是否有高清 **/
    public boolean hasHd;
    /** 当前视频是否有标清 **/
    public boolean hasStandard;
    /** 当前视频是否有极速 **/
    public boolean hasLow;

    // ---- 硬解 ----
    /** 当前视频是否有超清 **/
    public boolean hasHWSuperHd = false;
    /** 当前视频是否有高清 **/
    public boolean hasHWHd = false;
    /** 当前视频是否有标清 **/
    public boolean hasHWStandard = false;
    /** 当前视频是否有极速 **/
    public boolean hasHWLow = false;

    public void reset() {
        hasSuperHd = false;
        hasHd = false;
        hasStandard = false;
        hasLow = false;
        hasHWSuperHd = false;
        hasHWHd = false;
        hasHWStandard = false;
        hasHWLow = false;
    }

    public void resetHW() {
        hasHWSuperHd = false;
        hasHWHd = false;
        hasHWStandard = false;
        hasHWLow = false;
    }

    public void init(DDUrlsResultBean result) {
        hasSuperHd = result.isHasSuperHigh();
        hasHd = result.isHasHigh();
        hasStandard = result.isHasStandard();
        hasLow = result.isHasLow();
    }

    public void initHW(DDUrlsResultBean result) {
        int supportLevel = PlayUtils.getMaxStreamLevel();
        LogInfo.log("zhuqiao", "----LetvMediaPlayerManager.getInstance().supportLevel" + supportLevel);
        if (supportLevel == 4) {
            hasHWSuperHd = result.isHasSuperHigh();
        }
        if (supportLevel >= 3) {
            hasHWHd = result.isHasHigh();
        }
        if (supportLevel >= 2) {
            hasHWStandard = result.isHasStandard();
        }
        if (supportLevel >= 1) {
            hasHWLow = result.isHasLow();
        }
    }

    public int getStreamCount(List<Integer> levelList) {
        int streamCount = 0;

        levelList.clear();

        if (hasSuperHd) {
            levelList.add(PLAY_LEVEL.SUPERHIGH);
            streamCount++;
        }
        if (hasHd) {
            levelList.add(PLAY_LEVEL.HIGH);
            streamCount++;
        }
        if (hasStandard) {
            levelList.add(PLAY_LEVEL.STANDARD);
            streamCount++;
        }
        if (hasLow) {
            levelList.add(PLAY_LEVEL.LOW);
            streamCount++;
        }

        return streamCount;
    }
}
